package day6;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Demo10 {
    public static void main(String[] args) {
        String str = "我有一批玉玺出售，价格从优，量大优惠，请速联系本人，电话是15800033399，邮箱地址zhu@heaven.com";
        str = str + "本人求购一辆单车，价钱越低越好。最好免费赠送，请联系我电话是13480003397，邮箱地址sun@heaven.com.cn";
        str = str + "本人求购一辆单车，价钱越低越好。最好免费赠送，请联系我电话是134800033993413，邮箱地址sun@heaven.org.cn";
        str = str + "本人求购一辆单车，价钱越低越好。最好免费赠送，请联系我电话是13480003398，邮箱地址sunheaven.cc";

        String regex = "1[3|5|7|8|9]\\d{9}[^0-9]";
        String regex2 = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";
        Pattern pattern1 = Pattern.compile(regex2);
        Pattern pattern = Pattern.compile(regex);
        Matcher m = pattern.matcher(str);
        Matcher m1 = pattern1.matcher(str);
        while (m.find()){
            System.out.println(m.group().toString().substring(0, m.group().length() - 1));
        }
        while (m1.find()){
            System.out.println(m1.group());
        }
    }
}
